#include <stdlib.h>
#include <stdio.h>
#include "debug_time.h"

#define DEBUG_TIME_ID_NUM 1000

static long start_time_save[DEBUG_TIME_ID_NUM] = {0,};
static long stop_time_save[DEBUG_TIME_ID_NUM] = {0,};


void set_start_time(int id, long time)
{
#if DEBUG_TIME 
    if(id > DEBUG_TIME_ID_NUM)
		return;
    start_time_save[id] = time;
#endif
}

void set_stop_time(int id, long time)
{
#if DEBUG_TIME 
    if(id > DEBUG_TIME_ID_NUM)
		return;
    stop_time_save[id] = time;
#endif
}

long get_id_time(int id)
{
#if DEBUG_TIME 
	  if(id > DEBUG_TIME_ID_NUM)
		    return 0;
    return stop_time_save[id] - start_time_save[id];
#else
    return 0;
#endif
}

void printf_id_time(int id)
{
#if DEBUG_TIME 
	  if(id > DEBUG_TIME_ID_NUM)
		    return;
    printf("id%d=%ldms \n", id,  stop_time_save[id] - start_time_save[id]);
#else
    return 0;
#endif

}


void printf_id_time_name(int id, char* name)
{
#if DEBUG_TIME 
	  if(id > DEBUG_TIME_ID_NUM)
		    return;
    printf("%s(%d)=%ldms \n", name, id,  stop_time_save[id] - start_time_save[id]);
#else
    return 0;
#endif

}
